<?php 
	function connect()
	{
		define('DB_HOST', 'localhost');
		define('DB_USER', 'root');
		define('DB_PWO', '');
		define('DB_CHARSET', 'UTF8');
		define('DB_DBNAME', 'new_video');
		$DBConnect=@mysql_connect(DB_HOST,DB_USER,DB_PWO)
		OR die('数据库无法连接');
		mysql_set_charset(DB_CHARSET);//以下的数据库都以UTF8编码
		@mysql_select_db(DB_DBNAME,$DBConnect)
		or die('数据库不存在'); 
		return $DBConnect;
	}

	function fetch_array($Results)
	{
		$arrs = array();
		while ($Results && ($row=mysql_fetch_array($Results))!==FALSE) {   
			$arrs[]=$row;
		}
		return $arrs;
	}
	function add($tbl,$data)
	{
		$keys=implode(',',array_keys($data));
		$valued=implode(',',array_values($data));
		$sql="insert into $tbl($keys) values('$valued')";
		echo $sql;
		exit();
		/*$result=mysql_query($sql);
		if($result===false)
		{
			return 0;
		}
		else
		{
			return mysql_insert_id();
		}
*/
	}
 ?>

